<?php
declare (strict_types = 1);

namespace app\model;

use think\Model;

class Task extends Model
{
    // 设置表名
    protected $name = 'tasks';
    // 定义自动时间戳字段
    protected $autoWriteTimestamp = true;
    protected $createTime = 'created_at';
    protected $updateTime = 'updated_at';

    // 关联目标
    public function goal()
    {
        return $this->belongsTo(Goal::class, 'goal_id');
    }

    // 关联进度日志
    public function progressLogs()
    {
        return $this->hasMany(ProgressLog::class, 'task_id');
    }
}
